package com.ihmp.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.ihmp.model.TProductInRoomPriceHistory;
import com.ihmp.service.IProductInRoomService;

@Controller
public class ProductInRoomPriceHistory {
	
	@Autowired
	private IProductInRoomService productInRoomService;
	
	@RequestMapping(value="/accommodation/product-in-room-price-history.html",method=RequestMethod.GET)
	public ModelAndView mainScreen(@ModelAttribute("command") TProductInRoomPriceHistory productPriceHistory,
			 					   BindingResult result){
		Map<String,Object> model = getStandardModel();
		return new ModelAndView("accommodation/product-in-room-price-history",model);
	}
	
	@RequestMapping(value="/accommodation/add-product-price-history.html",method=RequestMethod.POST)
	public ModelAndView save(@ModelAttribute("command") TProductInRoomPriceHistory productPriceHistory,
							 BindingResult result){
		Map<String,Object> model = getStandardModel();
		return new ModelAndView("accommodation/product-in-room-price-history",model);
	}
	
	@RequestMapping(value="/accommodation/update-product-price-history.html",method=RequestMethod.POST)
	public ModelAndView update(@ModelAttribute("command") TProductInRoomPriceHistory productPriceHistory,
			 				   BindingResult result){
		Map<String,Object> model = getStandardModel();		
		return new ModelAndView("accommodation/product-in-room-price-history",model);
	}
	
	@RequestMapping(value="/accommodation/delete-product-price-history.html",method=RequestMethod.POST)
	public ModelAndView delete(@ModelAttribute("command") TProductInRoomPriceHistory productPriceHistory,
			 				   BindingResult result){
		Map<String,Object> model = getStandardModel();
		return new ModelAndView("accommodation/product-in-room-price-history",model);
	}
	
	@RequestMapping(value="/accommodation/search-product-price-history.html",method=RequestMethod.POST)
	public ModelAndView search(@RequestParam Integer productId,@RequestParam(required=false) Integer onlyNewPrice){				
		HashMap<String, Object> model = getStandardModel();
		System.out.println(productId);
		System.out.println(onlyNewPrice);
		return new ModelAndView("accommodation/product-in-room-price-history.html",model);
	}
	
	private HashMap<String, Object> getStandardModel(){
		HashMap<String, Object> model = new HashMap<String,Object>();
		model.put("pageTitle","Lịch sử giá sản phẩm dịch vụ trong phòng");
		model.put("productList",productInRoomService.getComboData());
		return model;
	}
}
